package com.atguigu.gulimall.member.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class MyRedisConfig {

    /**
     * 所有对redisson的使用,都是通过redissonClient对象进行操作的
     **/
    @Bean(destroyMethod = "shutdown")
    RedissonClient redisson() throws IOException {
        Config config = new Config();
       /* config.useClusterServers()
                .addNodeAddress("127.0.0.1:7004", "127.0.0.1:7001");*/
        config.useSingleServer().setAddress("redis://120.79.3.162:6379").setPassword("qinchuxun");

        //根据config创建redissClient实例
        RedissonClient redissonClient = Redisson.create(config);
        return redissonClient;
    }
}
